﻿using log4net;
using Microsoft.AspNetCore.Mvc;
using PhysicalExamination5.Interface.DataMaintenance;
using PhysicalExamination5.Interface.PhysicalExaminationManagement;
using PhysicalExamination5.WebApi.Utility.JWT;

namespace PhysicalExamination5.WebApi.Controllers.PhysicalExaminationManagement
{
    /// <summary>
    /// 单位维护
    /// </summary>
    [ApiController]
    [ApiVersion("1.0")]
    [Route("[controller]/v{version:apiVersion}")]
    public class DanWeiWeiHuController : Controller
    {
        private readonly IDanWeiWeiHu _IDanWeiWeiHu;
        private readonly ICustomJWTService _ICustomJWTService;
        private readonly IHttpContextAccessor _httpContextAccessor;
        private static readonly ILog log = LogManager.GetLogger(typeof(IndexController));

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="IDanWeiWeiHu"></param>
        /// <param name="ICustomJWTService"></param>
        /// <param name="httpContextAccessor"></param>
        public DanWeiWeiHuController(IDanWeiWeiHu IDanWeiWeiHu, ICustomJWTService ICustomJWTService, IHttpContextAccessor httpContextAccessor)
        {
            _IDanWeiWeiHu = IDanWeiWeiHu;
            _ICustomJWTService = ICustomJWTService;
            _httpContextAccessor = httpContextAccessor;

            //配置日志ip地址参数信息
            string ipAddress = _httpContextAccessor.HttpContext.Connection.RemoteIpAddress.ToString();
            log4net.GlobalContext.Properties["localIpAddress"] = ipAddress;
        }
    }
}
